﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>

<c:set var="baseUri" value="${pageContext.request.contextPath }"
       scope="request"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图书管理系统</title>
    <link rel="stylesheet" href="${baseUri}/static/layui/css/layui.css">
</head>
<body>
<!-- 内容主体区域 -->
<fieldset class="layui-elem-field layui-field-title"
          style="margin-top: 20px;">
    <legend>图书借阅信息</legend>
</fieldset>

<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="130">
            <col width="120">
            <col width="100">
            <col width="80">
            <col width="100">
            <col width="350">
            <col width="120">
            <col width="100">
            <col width="100">
            <col width="100">
        </colgroup>
        <thead>
        <tr>
            <th  style="text-align: center">ISBN</th>
            <th  style="text-align: center">书名</th>
            <th  style="text-align: center">作者</th>
            <th  style="text-align: center">类型</th>
            <th  style="text-align: center">价格(元)</th>
            <th  style="text-align: center">简介</th>
            <th  style="text-align: center">图片</th>
            <th  style="text-align: center">数量(剩/总)</th>
            <th  style="text-align: center">图书操作</th>
            <th  style="text-align: center">借阅操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${requestScope.pageMsg.lists}" var="book" varStatus="loop">
        <tr>
            <td>${book.isbn }</td>
            <td>${book.title }</td>
            <td>${book.author }</td>
            <td><c:if test="${book.categoryId==1 }">小说</c:if> <c:if
                    test="${book.categoryId==2 }">文学</c:if> <c:if
                    test="${book.categoryId==3 }">动漫</c:if> <c:if
                    test="${book.categoryId==4 }">文化</c:if> <c:if
                    test="${book.categoryId==5 }">传记</c:if> <c:if
                    test="${book.categoryId==6 }">艺术</c:if> <c:if
                    test="${book.categoryId==7 }">童书</c:if> <c:if
                    test="${book.categoryId==8 }">古籍</c:if> <c:if
                    test="${book.categoryId==9 }">历史</c:if></td>
            <td>${book.price }</td>
            <td>${book.introduction }</td>
            <td>
                <c:if test="${book.image==null}">
                    <img src="${baseUri}/static/images/book.jpg" width="80px" height="100px;">
                </c:if>
                <c:if test="${book.image !=null }">
                    <c:if test="${book.image=='' }">
                        <img src="${baseUri}/static/images/book.jpg" width="80px" height="100px;">
                    </c:if>
                    <c:if test="${book.image !='' }">
                        <img src="${imgPath}/${book.image}" alt="" width="80px" height="100px;">
                    </c:if>
                </c:if>
            </td>
            <td>${book.remainder }/${book.sum }</td>
            <!-- 同时遍历两个List的方法 ${键名[loop.count-1].属性名}  注：forEach里加varStatus="loop"-->
            <td><a class="layui-btn"
                   style="background-color: cadetblue"
                   href="bookDetail?id=${book.id }">查看</a>
                <c:if test="${msAdmin.identityId==0 }"> <!-- 管理员身份 -->
                    <br><br>
                    <a class="layui-btn"
                       style="background-color: rgb(204, 139, 41)" href="toUpdateBook?id=${book.id }">编辑</a>
                    <br><br>
                    <a class="layui-btn" id="soldBook"
                       style="background-color: rgb(211, 26, 81)"
                       href="deleteBook?id=${book.id }">下架</a>
                </c:if>
            </td>
            <td>
                <a class="layui-btn" style="background-color: rgb(204, 139, 41)"
                   href="toReturnBook?id=${book.id }&readerId=${readerId }&from=borrowBook">归还</a>
                <br><br>
                    <a class="layui-btn"
                       style="background-color: rgb(204, 139, 41)"
                       href="toRenewBook?id=${book.id }&readerId=${readerId }&from=borrowBook">续借</a>
<%--                <c:if test="${(borrowList[loop.count-1].borrowBooking != null) && (book.remainder == 0) }"> <!-- 预约中 -->--%>
<%--                    <a class="layui-btn"--%>
<%--                       style="background-color: rgb(204, 139, 41)">预约中</a>--%>
<%--                </c:if>--%>
<%--                <c:if test="${(borrowList[loop.count-1].borrowBooking != null) && (book.remainder > 0) }"> <!-- 可领取 -->--%>
<%--                    <a class="layui-btn"--%>
<%--                       style="background-color: rgb(204, 139, 41)"--%>
<%--                       href="toTakeBook?id=${book.id }&readerId=${readerId }&from=borrowBook">可领取</a>--%>
<%--                </c:if>--%>
            </td>
        </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<script src="${baseUri}/static/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1',
            width: '100%' //设置容器宽度
            ,
            arrow: 'always' //始终显示箭头
            //,anim: 'updown' //切换动画方式
        });
    });
    layer.open({
        type: 4,
        content: ['已下架', '#soldBook']
        //数组第二项即吸附元素选择器或者DOM
    });
</script>
</body>
</html>